<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="./lib/axios.js"></script>
    <script>
        // axios中有一个全局配置,可以设置所有ajax的基础路径,但是只有配置之后才生效
        axios.defaults.baseURL = 'http://www.liulongbin.top:3009';

        // 1.简写get
        axios.get('/api/getbooks').then(({data:res}) =>{
            console.log(res);
        })
        // 2.简写post
        axios.post('/api/getbooks').then(({data:res}) =>{
            console.log(res);
        })
        // 3.完整写法
        axios({
            method:'get',
            url:'/api/getbooks'
        }).then(({data:res})=>{
            console.log(res);
        })
    </script>
</body>
</html>